package helper;

import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.io.WritableComparator;

public class PairGroupingComparator extends WritableComparator {
	 
	protected PairGroupingComparator() {
		super(CompositeKey.class, true);
	}
 
	@SuppressWarnings("rawtypes")
	@Override
	public int compare(WritableComparable w1, WritableComparable w2) {
		CompositeKey key1 = (CompositeKey) w1;
		CompositeKey key2 = (CompositeKey) w2;
 
		int compare = Integer.compare(key1.getUser(), key2.getUser());
//        if (compare == 0) {
//        // only if we are in the same input group should we try and sort by value (num)
//            return Integer.compare(key2.getNum(), key1.getNum());
//        }
        
        return compare;
	}
}
